//
//  ShareTextController.m
//  PosApp
//
//  Created by 刘萍 on 2018/9/12.
//  Copyright © 2018年 李英新. All rights reserved.
//

#import "ShareTextController.h"
#import "ShareItemController.h"

@interface ShareTextController ()



@property (weak, nonatomic) IBOutlet UIImageView *ShareImage;

@property (weak, nonatomic) IBOutlet UIButton *ShareTCBotBtn01;

@property (weak, nonatomic) IBOutlet UIButton *ShareTCBotBtn02;
@end

@implementation ShareTextController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.navigationItem.title = @"素材库";
    self.ShareTCBotBtn01.layer.borderWidth = 1;
    self.ShareTCBotBtn01.layer.borderColor = KRGBColor(255, 0, 102).CGColor;
}
- (IBAction)ClickOnBtnToTheWebViewWithTheUrl:(id)sender {
    
    
}

- (IBAction)ClickOnBtnOfBotBtn01ToShare:(id)sender {
    UIImageWriteToSavedPhotosAlbum(self.ShareImage.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}



- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
    NSString *msg = nil ;
    if(error != NULL){
        msg = @"保存图片失败" ;
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *cancel  =[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        }];
        [alert addAction:cancel];
        [self presentViewController:alert animated:YES completion:^{
        }];
        
    }else{
        [MBProgressHUD showAlertViewWithText:@"下载成功"];
    }
}
- (IBAction)ClickOnBtnOfBotBtn02ToShare:(id)sender {
    
    ShareItemController * shareC = [[ShareItemController alloc] init];
    shareC.modalPresentationStyle = UIModalPresentationOverFullScreen;
    [self presentViewController:shareC animated:YES completion:nil];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
